<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property string $name 
 * @property string $url 
 * @property string $brief 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class MyObject extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'my_objects';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function getUrlAttribute($value)
    {
        if (empty($value)) {
            return '';
        }
        if (strpos($value, 'http') !== false) {
            return $value;
        }
        return 'http://zhihui-1257468331.cos.ap-beijing.myqcloud.com/' . $value;
    }
}